<template>
	<view class="mainpadding2">
		<view class="mainpadding_top ffffff radius">
			<view class="flexbetween">
				<view class="titletext bold hei_text">#{{orderInfo.call_no}}</view>
				<!-- <view class="main_size bold huang_text">{{Number(orderInfo.old)+Number(orderInfo.adult)+Number(orderInfo.child)}}人用餐</view> -->
			</view>
			<view class="mainpadding_top bghui radius">
				<view class="flexcolumn">
					<view class="huang_text bold" style="font-size: 40rpx;">{{orderInfo.desk}}</view>
					<view class="hei_text main_size bold margin_top1">使用號</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff radius" v-if="orderInfo.goods_data.length">
			<view class="titletext hei_text bold">已點商品</view>
			<view class="pdl" v-for="item in orderInfo.goods_data" :key="item.id">
				<view class="flexleft margin_top">
					<view class="listleftimg radius margin_right">
						<image class="listleftimg radius" :src="item.logoimage" mode=""></image>
					</view>
					<view style="width: 100%;">
						<view class="hei_text main_size bold">{{item.goods_name}}</view>
						<view class="xiaohui" v-if="item.wei || item.hei">尺寸：{{item.wei}}*{{item.hei}}
							{{item.formulacount}}{{item.size}}</view>
						<view class="xiaohui" v-if="item.spunatname">規格：{{item.spunatname}}</view>
						<view class="flexbetween">
							<view class="main_size huang_text bold">${{item.price}}</view>
							<view class="xiaohuang">x{{item.num}}</view>
						</view>
					</view>
				</view>
				<view class="flexright margin_top2" v-show="orderInfo.status==5">
					<view class="listbtnhuang" v-show="orderInfo.type==2&&item.is_sell==0"
						@click.stop="singleShipment(item,orderInfo)">出貨</view>
					<view class="listbtnhui" v-show="orderInfo.type==2&&item.is_sell==1">已出貨</view>
				</view>
				<!-- <view class="flexbetween margin_top2">
					<view class="hui_text main_size">优惠券</view>
					<view class="huang_text main_size">-$238</view>
				</view> -->
				<!-- <view class="flexbetween margin_top" v-if="item.addimage">
					<view class="flexleft">
						<image src="../../static/image/system/wenjian.png" style="width: 56rpx;height: 56rpx;"
							mode="">
						</image>
						<view class="titletext hei_text bold margin_left">客户文件</view>
					</view>
					<view class="flexright">
						<view class="listbtnhuang margin_left2" @click="downfile(item)">立即下载</view>
					</view>
				</view> -->
			</view>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="titletext hei_text bold">訂單資訊</view>
			<view class="flexbetween margin_top" v-if="orderInfo.order_type!=3">
				<view class="hei_text main_size bold">用餐人數</view>
				<view class="hui_text main_size bold">
					老人：{{orderInfo.old}}，客戶：{{orderInfo.adult}}，兒童：{{orderInfo.child}}，共{{Number(orderInfo.old)+Number(orderInfo.adult)+Number(orderInfo.child)}}人
				</view>
			</view>
			<view class="hei_text margin_top  main_size bold" v-if="orderInfo.order_type==3">
				用餐人數：<text class="hui_text main_size bold" v-for="(item,index) in JSON.parse(orderInfo.cdbjhsf_data)"
					:key="index">
					<text v-if="item.num" class="margin_right1"><text
							class="huang_text">{{item.num}}</text>/{{item.name}}</text>
				</text>
			</view>
			<view class="flexbetween margin_top">
				<view class="hei_text main_size bold">下單時間</view>
				<view class="hui_text main_size bold">{{secondDate(orderInfo.createtime,0,0)}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="hei_text main_size bold">訂單編號</view>
				<view class="hui_text main_size bold">{{orderInfo.order_sn}}</view>
			</view>
			<view class="flexbetween margin_top" v-if="orderInfo.order_type==3">
				<view class="hei_text main_size bold">人數基本價</view>
				<view class="huang_text main_size bold">${{orderInfo.rs_price}}</view>
			</view>
			<view class="flexbetween margin_top" v-if="orderInfo.order_type==3">
				<view class="hei_text main_size bold">商品總金額</view>
				<view class="huang_text main_size bold">
					${{Number(orderInfo.countmoney)-Number(orderInfo.rs_price)-Number(orderInfo.fw_price)}}
				</view>
			</view>
			<view class="flexbetween margin_top" v-if="orderInfo.order_type==3">
				<view class="hei_text main_size bold">服務費用</view>
				<view class="huang_text main_size bold">${{orderInfo.fw_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="hei_text main_size bold">總金额</view>
				<view class="huang_text main_size bold">${{orderInfo.countmoney}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="hei_text main_size bold">已付金额</view>
				<view class="huang_text main_size bold">${{orderInfo.paymoney}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="hei_text main_size bold">未付金额</view>
				<view class="hong_text main_size bold">${{Number(orderInfo.countmoney) - Number(orderInfo.paymoney)}}
				</view>
			</view>
			<view class="flexbetween margin_top" v-if="orderInfo.paytype!=0">
				<view class="hei_text main_size bold">支付方式</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==1">點數支付</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==2">多元支付</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==3">現金支付</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==4">信用卡</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==5">Line Pay線上支付
				</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==6">街口線上支付
				</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==7">街口線下支付
				</view>
				<view class="hui_text main_size bold" v-if="orderInfo.paytype==8">Line Pay線下支付
				</view>
				<view class="hui_text main_size bold" v-show="orderInfo.paytype==9">Line Pay二維碼支付
				</view>
				<view class="hui_text main_size bold" v-show="orderInfo.paytype==10">街口二維碼支付
				</view>
				<view class="hui_text main_size bold" v-show="orderInfo.paytype==11">全支付線下支付
				</view>
			</view>
			<template v-if="orderInfo.paytype==6 || orderInfo.paytype==7">
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">街口券折抵 </view>
					<view class="hui_text main_size bold">${{orderInfo.RedeemAmount}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">街口幣折抵 </view>
					<view class="hui_text main_size bold">${{orderInfo.StoreRedeemAmount}}</view>
				</view>
			</template>
			<template v-if="orderInfo.paytype==5 || orderInfo.paytype==8">
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">LINE POINTS折抵 </view>
					<view class="hui_text main_size bold">${{orderInfo.RedeemAmount}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size bold">LINE 優惠券折抵 </view>
					<view class="hui_text main_size bold">${{orderInfo.StoreRedeemAmount}}</view>
				</view>
			</template>
		</view>
		<view class="submitbtn margin_top" v-if="Number(orderInfo.countmoney) - Number(orderInfo.paymoney)"
			@click="shoukuan(orderInfo)">收款</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderInfo: "",
				pageShow: false,
				id: "", //物流配送的订單id
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		onShow() {
			this.getInfo()
		},
		methods: {
			shoukuan(item) {
				if (item.order_type == 1 || item.order_type == 4) {
					uni.navigateTo({
						url: "/pages/goodsOrder/goodssk?total_price=" + item.zhuimoney + "&id=" + item.id
					})
				} else {
					uni.navigateTo({
						url: "/pages/yuYueOrder/yuyuesk?total_price=" + item.zhuimoney + "&id=" + item.order_make
							.id
					})
				}
			},
			xianjinsk(item) {
				this.http.modal('', '請確認是否完成現金收款', true, (res) => {
					if (res) {
						this.http.request('/api/ordergoods/endzhuimoney', 'POST', {
							id: item.id,
						}).then(res => {
							if (res.code == 1) {
								this.http.toast("現金收款完成")
								this.getInfo()
							} else {
								this.http.toast(res.msg)
							}
						})
					}
				})
			},
			async getInfo() { //订單详情
				let res = await this.http.request('/api/Ordergoods/deailOrdergoods', 'POST', {
					id: this.id
				})
				if (res.code == 1) {
					let goods_allprice = 0
					res.data.goods_data.forEach(value => {
						value.logoimage = this.imgUrlUser + value.logoimage
						goods_allprice = Number(value.price) + Number(goods_allprice)
					})
					this.$set(res.data, "goods_allprice", goods_allprice)
					this.orderInfo = res.data
					this.pageShow = true
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
		}
	}
</script>

<style>

</style>